package zhaoxue.controller;

import zhaoxue.entity.BjEntity;
import zhaoxue.entity.Page;
import zhaoxue.entity.PageUtils;
import zhaoxue.entity.ZhaoXueEntity;
import zhaoxue.service.ZhaoXueService;

import javax.annotation.Resource;
import java.util.List;

public class ZhaoXueController {
    ZhaoXueEntity zhaoXueEntity=null;
    String name = null;
    Integer pageNo = null;
    Page page =  null;
    List<BjEntity> bjEntity=null;
    String flag = "0";
    @Resource
    ZhaoXueService zhaoXueService;

    public String queryPage(){
        int totalCount= zhaoXueService.queryCount(name);
        page = PageUtils.getPage(5,totalCount,pageNo);
        List<ZhaoXueEntity> list = zhaoXueService.queryPage(page,name);
        page.setData(list);
        return "queryPage";
    }

    public String save(){
        zhaoXueService.save(zhaoXueEntity);
        flag = "1";
        return "save";
    }
    public String del(){
        zhaoXueService.del(zhaoXueEntity);
        flag = "1";
        return "save";
    }

    public String edit(){
        zhaoXueEntity =zhaoXueService.edit(zhaoXueEntity);

        return "edit";
    }

    public String bj(){
        bjEntity =zhaoXueService.bj();
        return "bj";
    }

    public ZhaoXueEntity getZhaoXueEntity() {
        return zhaoXueEntity;
    }

    public void setZhaoXueEntity(ZhaoXueEntity zhaoXueEntity) {
        this.zhaoXueEntity = zhaoXueEntity;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getPageNo() {
        return pageNo;
    }

    public void setPageNo(Integer pageNo) {
        this.pageNo = pageNo;
    }

    public Page getPage() {
        return page;
    }

    public void setPage(Page page) {
        this.page = page;
    }

    public List<BjEntity> getBjEntity() {
        return bjEntity;
    }

    public void setBjEntity(List<BjEntity> bjEntity) {
        this.bjEntity = bjEntity;
    }

    public String getFlag() {
        return flag;
    }

    public void setFlag(String flag) {
        this.flag = flag;
    }
}
